package com.sky.task;

import com.sky.entity.Orders;
import com.sky.mapper.OrdersMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Slf4j
@Component
public class OrderScheduling {
    @Autowired
    OrdersMapper ordersMapper;
    @Scheduled(cron = "*/5 * * * * ?")
    public void orderCs(){
      List<Orders>list= ordersMapper.Orderlist();
        for (Orders orders : list) {
            LocalDateTime orderTime = orders.getOrderTime();
            LocalDateTime now = LocalDateTime.now();
            boolean after = now.minusMinutes(15).isAfter(orderTime);

            if (!after){
                continue;//如果不是结束当前循环
            }
            ordersMapper.quxiao();
        }


    }
}
